package org.linlinjava.litemall.wx.web;

import com.github.pagehelper.Page;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.linlinjava.litemall.core.util.ResponseUtil;
import org.linlinjava.litemall.db.domain.LitemallWithdraw;
import org.linlinjava.litemall.db.service.LitemallUserService;
import org.linlinjava.litemall.db.vo.IncomeOrderVo;
import org.linlinjava.litemall.wx.annotation.LoginUser;
import org.linlinjava.litemall.wx.service.WxUserIncomeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户统计
 */
@RestController
@RequestMapping("/wx/income")
@Validated
public class WxUserIncomeController {
    private final Log logger = LogFactory.getLog(WxUserIncomeController.class);

    @Autowired
    private WxUserIncomeService userIncomeService;

    /**
     * 推广收益
     * @param userId
     * @return
     */
    @GetMapping("list")
    public Object promote(@LoginUser Integer userId,
                  @RequestParam(defaultValue = "") Integer showType,
                  @RequestParam(defaultValue = "1") Integer page,
                  @RequestParam(defaultValue = "10") Integer limit) {
        if (userId == null) {
            return ResponseUtil.unlogin();
        }
        Page<IncomeOrderVo> couponList =  userIncomeService.queryList(userId,showType,page,limit);
        return ResponseUtil.okList(couponList);
    }

}
